package com.app.micaihu.view.main.game;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.app.micaihu.R;
import com.app.micaihu.app.AppApplication;
import com.app.micaihu.base.BaseOldActivity;

import com.app.micaihu.configure.Config;
import com.app.micaihu.view.main.game.fragment.GameRankingFragment;
import com.app.utils.util.StringUtils;
import com.baidu.mobstat.StatService;

/**
 * Created by Guo on 2017/3/23.
 * <p>
 * <p>
 * 游戏排行的activity
 */

public class GameRankingActivity extends BaseOldActivity implements View.OnClickListener {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addContentView(R.layout.activity_game_ranking);
        //改变通知栏顶部
        pageConfigNotify = true;
        //初始化页面控件
        initView();
        //加载页面数据
    }


    private void initView() {
        setTitle(AppApplication.getInstance().getString(R.string.game_ranking));
        setTitleRightImage(R.drawable.mygame_btn_selector);
        findViewById(R.id.page_head_function).setOnClickListener(this);


        String stringExtra = getIntent().getStringExtra(Config.Extra.PARAMETER1);

        FragmentManager supportFragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();

        GameRankingFragment gameRankingFragment = new GameRankingFragment();

        //因为基类是懒加载的.所以这里调用一下显示
        gameRankingFragment.changeVisi(true);
        Bundle bundle = new Bundle();

        if (StringUtils.isEmpty(stringExtra)) {
            bundle.putString(Config.Extra.PARAMETER1, GameRankingFragment.ALLRANK);
        } else {
            bundle.putString(Config.Extra.PARAMETER1, stringExtra);
        }
        gameRankingFragment.setArguments(bundle);
        fragmentTransaction.add(R.id.fragment, gameRankingFragment);
        fragmentTransaction.commit();


    }


    @Override
    public void onClick(View v) {
        if (v == null) return;
        if (v.getId() == R.id.page_head_function) {
            startActivity(new Intent(GameRankingActivity.this, GameDownloadActivity.class));
            StatService.onEvent(GameRankingActivity.this, "007", "右上角我的游戏", 1);//统计事件的点击次数
        }
    }
}
